package com.bbc.third.taobao;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.ItemGetRequest;
import com.taobao.api.request.ItemcatsGetRequest;
import com.taobao.api.request.ShopGetRequest;
import com.taobao.api.response.ItemGetResponse;
import com.taobao.api.response.ItemcatsGetResponse;
import com.taobao.api.response.ShopGetResponse;

public class T {
	private static final String serverUrl = "http://gw.api.taobao.com/router/rest";
	private static final String appKey = "21253684";
	private static final String appSecret = "f680b5d32a6acd2e52bebbda8b974930";
	
	public static void main(String[] args) {
		getType();
	}
	
	public static void getType() {
		TaobaoClient client=new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "21253684", "f680b5d32a6acd2e52bebbda8b974930");
		ItemcatsGetRequest req=new ItemcatsGetRequest();
		req.setFields("cid,parent_cid,name,is_parent");
		//req.setParentCid(0L); 
		req.setCids("0");
		try {
			ItemcatsGetResponse response = client.execute(req);
			System.out.println(response.getBody());
		} catch (ApiException e) {
			e.printStackTrace();
		}
	}
	
	
	public static void getProduct() {
		TaobaoClient client=new DefaultTaobaoClient(serverUrl, appKey, appSecret);
		ItemGetRequest req=new ItemGetRequest();
		req.setFields("detail_url,num_iid,title,nick,type,cid,pic_url,price,approve_status");
		req.setNumIid(9928105769L);
		try {
			ItemGetResponse response = client.execute(req);
			System.out.println(response);
		} catch (ApiException e) {
			e.printStackTrace();
		}
	}
	
	public static void getShop() {
		TaobaoClient client=new DefaultTaobaoClient(serverUrl, appKey, appSecret);
		ShopGetRequest req=new ShopGetRequest();
		req.setFields("sid,cid,nick,title,pic_path,shop_score");
		req.setNick("魅力永恒131488");
		try {
			ShopGetResponse response = client.execute(req);
			System.out.println(response.getBody());
		} catch (ApiException e) {
			e.printStackTrace();
		}
	}

}
